$(function() {
  $(".nav.navbar-nav").children(":eq(3)").addClass("active").siblings(".active").removeClass("active")
  $.get("./miner.shtml", function(data) {
    console.log(data);
    $(".hashrate-total").text(unitCover(data.hashrate))
    $(".miner-total").text(data.minersTotal)
    $.each(data.miners, function(key, item) {
      var $tr = $("<tr>"),
        $td = $("<td>").appendTo($tr);
      $("<a>").attr("href", "./miner.html?minerId=" + item.hash).text(item.hash).appendTo($td);
      $("<td>").text(unitCover(item.hr)).appendTo($tr);
      $("<td>").text(dateFormat(item.lastBeat * 1000, 'yyyy-MM-dd hh:mm:ss')).appendTo($tr);
      $tr.appendTo($(".miners"));
    });

    $('#minersTable').DataTable({
      "paging": false,
      "info": false,
      'bSort': false,
      "stateSave": true,
      'language': {
        "search": "搜索:",
      }
    });
  })
});